import { QuestionCircleFilled } from "@ant-design/icons"
import { Tooltip } from "antd"
import { ColumnGroupType, ColumnType } from "antd/es/table"

import { ICardTablesBaseSettlementListResponse } from "@/api/business/types"
import { formatHyphen, formatTime, handleNumber, handleNumberColor } from "@/utils/util"

const settle = (
	newFormat: (arg: string) => string,
	_getFromDic: (arg: string, strictlyLabel?: boolean) => any,
	renderColor: (arg: number | string) => JSX.Element
): Record<string, ColumnGroupType<any> | ColumnType<any>> => ({
	userNameSettle: {
		key: "userName",
		align: "center",
		dataIndex: "userName",
		title: newFormat("dxn.card_ables_list.member_account"),
		width: 100
	},
	nickNameSettle: {
		key: "nickName",
		align: "center",
		dataIndex: "nickName",
		title: newFormat("dxn.card_ables_list.member_name"),
		width: 100
	},
	handBeginDateSettle: {
		key: "handBeginDate",
		align: "center",
		dataIndex: "handBeginDate",
		title: newFormat("dxn.card_ables_list.start_time"),
		width: 100,
		render: (text: string) => formatTime(text)
	},
	handEndDateSettle: {
		key: "handEndDateSettle",
		align: "center",
		dataIndex: "handEndDate",
		title: newFormat("dxn.card_ables_list.end_time"),
		width: 100,
		render: (text: string) => formatTime(text)
	},
	numberOfStepsSettle: {
		key: "numberOfStepsSettle",
		align: "center",
		dataIndex: "handCount",
		title: newFormat("dxn.card_ables_list.number_of_steps"),
		width: 80,
		render: (text: number) => formatHyphen(text)
	},
	tableCodeSettle: {
		key: "tableCodeSettle",
		align: "center",
		dataIndex: "tableCode",
		title: newFormat("dxn.card_ables_list.table_id"),
		width: 180
	},
	costTotalSettle: {
		key: "costTotalSettle",
		align: "center",
		dataIndex: "memberCurrency",
		title: (
			<Tooltip title={newFormat("dxn.card_ables_list.cost_total_tips")}>
				{newFormat("dxn.card_ables_list.total_win_loss")}
				<QuestionCircleFilled />
			</Tooltip>
		),
		width: 80,
		render: (memberCurrency: string, record: ICardTablesBaseSettlementListResponse) => (
			<div style={{ color: handleNumberColor(record.costTotal) }}>{handleNumber(memberCurrency, `${record.costTotal}`)}</div>
		)
	},
	bringOutChipScoreSettle: {
		key: "bringOutChipScoreSettle",
		align: "center",
		dataIndex: "memberCurrency",
		title: newFormat("dxn.card_ables_list.always_bring_out"),
		width: 100,
		render: (memberCurrency: string, record: ICardTablesBaseSettlementListResponse) =>
			handleNumber(memberCurrency, record.bringOutChipScore.toString())
	},
	bringMidwayChipSettle: {
		key: "bringMidwayChipSettle",
		align: "center",
		dataIndex: "memberCurrency",
		title: newFormat("dxn.card_ables_list.total_carried_in"),
		width: 100,
		render: (memberCurrency: string, record: ICardTablesBaseSettlementListResponse) =>
			handleNumber(memberCurrency, `${record.bringMidwayChip}`)
	},
	bringCountSettle: {
		key: "bringCountSettle",
		align: "center",
		dataIndex: "bringCount",
		title: newFormat("dxn.card_ables_list.number_times_in"),
		width: 100
	},
	netAmountSettle: {
		key: "netAmountSettle",
		align: "center",
		dataIndex: "memberCurrency",
		title:
			newFormat("dxn.card_ables_list.winning_or_losing_in_card_games") +
			`(${newFormat("dxn.card_ables_list.including_hand_service_fee")})`,
		width: 120,
		render: (memberCurrency: string, record: ICardTablesBaseSettlementListResponse) =>
			handleNumber(memberCurrency, `${record.netAmount}`)
	},
	tableFeeSettle: {
		key: "tableFeeSettle",
		align: "center",
		dataIndex: "memberCurrency",
		title: newFormat("dxn.card_ables_list.bureau_service_fee"),
		width: 100,
		render: (memberCurrency: string, record: ICardTablesBaseSettlementListResponse) =>
			handleNumber(memberCurrency, `${record.tableFee}`)
	},
	insuredNetAmountSettle: {
		key: "insuredNetAmountSettle",
		align: "center",
		dataIndex: "memberCurrency",
		title: newFormat("dxn.card_ables_list.classic_insurance_winning_and_losing"),
		width: 100,
		render: (memberCurrency: string, record: ICardTablesBaseSettlementListResponse) => (
			<div style={{ color: handleNumberColor(record.insuredNetAmount) }}>
				{handleNumber(memberCurrency, `${record.insuredNetAmount}`)}
			</div>
		)
	},
	pumpContributionSettle: {
		key: "pumpContributionSettle",
		align: "center",
		dataIndex: "memberCurrency",
		title: newFormat("common.card_service_charge_contribute"),
		width: 100,
		render: (memberCurrency: string, record: ICardTablesBaseSettlementListResponse) =>
			handleNumber(memberCurrency, `${record.pumpContribution}`)
	},
	settle_grossProfit: {
		key: "settle_grossProfit",
		align: "center",
		dataIndex: "grossProfit",
		title: newFormat("dxn.card_ables_list.winning_and_losing_in_card_games"),
		width: 140,
		render: (grossProfit: number, record: any) => handleNumber(record.memberCurrency, `${grossProfit}`)
	},
	settle_netAmount: {
		key: "settle_netAmount",
		align: "center",
		dataIndex: "netAmount",
		title: newFormat("dxn.card_ables_list.winning_or_losing_in_card_games_after_pumping"),
		width: 140,
		render: (netAmount: number, record: any) => handleNumber(record.memberCurrency, `${netAmount}`)
	},
	settle_userHandFee: {
		key: "settle_userHandFee",
		align: "center",
		dataIndex: "userHandFee",
		title: newFormat("dxn.card_ables_list.play_cards_pump_water"),
		width: 140,
		render: (userHandFee: number, record: any) => handleNumber(record.memberCurrency, `${userHandFee}`)
	},
	settle_tableFee: {
		key: "settle_tableFee",
		align: "center",
		dataIndex: "tableFee",
		title: newFormat("dxn.card_ables_list.bureau_service_fee"),
		width: 140,
		render: (tableFee: number, record: any) => handleNumber(record.memberCurrency, `${tableFee}`)
	},
	settle_evInsuredNetAmount: {
		key: "settle_evInsuredNetAmount",
		align: "center",
		dataIndex: "evInsuredNetAmount",
		title: newFormat("dxn.card_ables_list.ev_insurance_win_or_loss"),
		width: 140,
		render: (evInsuredNetAmount: number, record: any) => (
			<div style={{ color: handleNumberColor(evInsuredNetAmount) }}>
				{handleNumber(record.memberCurrency, `${evInsuredNetAmount}`)}
			</div>
		)
	},
	settle_sendBarrageAmount: {
		key: "settle_sendBarrageAmount",
		align: "center",
		dataIndex: "sendBarrageAmount",
		title: newFormat("dxn.game_list.post_barrages"),
		width: 150,
		render: (sendBarrageAmount: number, record: any) => handleNumber(record.currency, `${sendBarrageAmount}`)
	},
	settle_sendEmoteAmount: {
		key: "settle_sendEmoteAmount",
		align: "center",
		dataIndex: "sendEmoteAmount",
		title: newFormat("dxn.game_list.send_an_emoji"),
		width: 150,
		render: (sendEmoteAmount: number, record: any) => handleNumber(record.currency, `${sendEmoteAmount}`)
	},
	settle_sendPuraseAmount: {
		key: "settle_sendPuraseAmount",
		align: "center",
		dataIndex: "sendPuraseAmount",
		title: newFormat("dxn.game_list.send_phrases"),
		width: 150,
		render: (sendPuraseAmount: number, record: any) => handleNumber(record.currency, `${sendPuraseAmount}`)
	},
	settle_sendVoiceAmount: {
		key: "tableList_sendVoiceAmount",
		align: "center",
		dataIndex: "sendVoiceAmount",
		title: newFormat("dxn.game_list.make_a_voice"),
		width: 150,
		render: (sendVoiceAmount: number, record: any) => handleNumber(record.currency, `${sendVoiceAmount}`)
	},
	settle_interactPropAmount: {
		key: "tableList_interactPropAmount",
		align: "center",
		dataIndex: "interactPropAmount",
		title: newFormat("dxn.game_list.interactive_props"),
		width: 150,
		render: (interactPropAmount: number, record: any) => handleNumber(record.currency, `${interactPropAmount}`)
	},
	settle_lookPublicCardAmount: {
		key: "tableList_lookPublicCardAmount",
		align: "center",
		dataIndex: "lookPublicCardAmount",
		title: newFormat("dxn.game_list.look_at_public_cards"),
		width: 150,
		render: (lookPublicCardAmount: number, record: any) => handleNumber(record.currency, `${lookPublicCardAmount}`)
	},
	settle_betActionDelayAmount: {
		key: "tableList_betActionDelayAmount",
		align: "center",
		dataIndex: "betActionDelayAmount",
		title: newFormat("dxn.game_list.delay_in_placing_bets"),
		width: 150,
		render: (betActionDelayAmount: number, record: any) => handleNumber(record.currency, `${betActionDelayAmount}`)
	},
	settle_insureActionDelayAmount: {
		key: "tableList_insureActionDelayAmount",
		align: "center",
		dataIndex: "insureActionDelayAmount",
		title: newFormat("dxn.game_list.insurance_action_delay"),
		width: 150,
		render: (insureActionDelayAmount: number, record: any) => handleNumber(record.currency, `${insureActionDelayAmount}`)
	},
	settle_pumpContribution: {
		key: "settle_pumpContribution",
		align: "center",
		dataIndex: "pumpContribution",
		title: newFormat("common.card_service_charge_contribute"),
		width: 150,
		render: (pumpContribution: number, record: any) => handleNumber(record.memberCurrency, `${pumpContribution}`)
	},
	settle_tableFeeContribution: {
		key: "settle_tableFeeContribution",
		align: "center",
		dataIndex: "tableFeeContribution",
		title: newFormat("common.game_service_charge_contribute"),
		width: 150,
		render: (tableFeeContribution: number, record: any) => handleNumber(record.memberCurrency, `${tableFeeContribution}`)
	},
	settle_contribution: {
		key: "settle_contribution",
		align: "center",
		dataIndex: "contribution",
		title: newFormat("common.service_charge"),
		width: 150,
		render: (contribution: number, record: any) => handleNumber(record.memberCurrency, `${contribution}`)
	},
	settle_bringOutChipScore: {
		key: "memberCurrency",
		dataIndex: "memberCurrency",
		title: newFormat("dxn.card_ables_list.players_bring_out2"),
		align: "center",
		width: 100,
		render: (memberCurrency: string, record: any) => handleNumber(memberCurrency, record.bringOutChipScore.toString())
	},
	settle_bringMidwayChipSettle: {
		key: "memberCurrency",
		dataIndex: "memberCurrency",
		title: newFormat("dxn.card_ables_list.table_marked_out"),
		align: "center",
		width: 100,
		render: (memberCurrency: string, record: any) => handleNumber(memberCurrency, record.tableTransToSquidAmount.toString())
	},
	settle_bringMidwayChip: {
		key: "memberCurrency",
		dataIndex: "memberCurrency",
		title: newFormat("dxn.card_ables_list.players_bring_in2"),
		align: "center",
		width: 100,
		render: (memberCurrency: string, record: any) => handleNumber(memberCurrency, record.bringMidwayChip.toString())
	},
	settle_squidBringOutAmount: {
		key: "memberCurrency",
		dataIndex: "memberCurrency",
		title: newFormat("dxn.card_ables_list.bring_out_the_squid_wallet"),
		align: "center",
		width: 100,
		render: (memberCurrency: string, record: any) => handleNumber(memberCurrency, record.squidBringOutAmount.toString())
	},
	settle_squidBringInAmount: {
		key: "memberCurrency",
		dataIndex: "memberCurrency",
		title: newFormat("dxn.card_ables_list.bring_in_squid_wallet"),
		align: "center",
		width: 100,
		render: (memberCurrency: string, record: any) => handleNumber(memberCurrency, record.squidBringInAmount.toString())
	},
	settle_squidPayAmount: {
		key: "memberCurrency",
		dataIndex: "memberCurrency",
		title: newFormat("member.squid_info.squid_payments"),
		align: "center",
		width: 100,
		render: (memberCurrency: string, record: any) => handleNumber(memberCurrency, record.squidPayAmount.toString())
	},
	settle_squidTransInAmount: {
		key: "memberCurrency",
		dataIndex: "memberCurrency",
		title: newFormat("dxn.card_ables_list.table_entry"),
		align: "center",
		width: 100,
		render: (memberCurrency: string, record: any) => handleNumber(memberCurrency, record.squidTransInAmount.toString())
	},
	settle_squidRound: {
		key: "squidRound",
		dataIndex: "squidRound",
		title: newFormat("dxn.card_ables_list.squid_rounds"),
		align: "center",
		width: 100
	},
	settle_squidRewardsAmount: {
		key: "memberCurrency",
		dataIndex: "memberCurrency",
		title: newFormat("dxn.card_ables_list.squid_mode_total_rewards"),
		align: "center",
		width: 100,
		render: (memberCurrency: string, record: any) => handleNumber(memberCurrency, record.squidRewardsAmount.toString())
	},
	settle_squidPayoutAmount: {
		key: "memberCurrency",
		dataIndex: "memberCurrency",
		title: newFormat("dxn.card_ables_list.total_payout_in_squid_mode"),
		align: "center",
		width: 100,
		render: (memberCurrency: string, record: any) => handleNumber(memberCurrency, record.squidPayoutAmount.toString())
	},
	settle_squidNetAmount: {
		key: "memberCurrency",
		dataIndex: "memberCurrency",
		title: newFormat("dxn.card_ables_list.squid_win_or_lose"),
		align: "center",
		width: 100,
		render: (_: string, record: any) => <span>{renderColor(`${record.squidNetAmount}`)}</span>
	}
})
export default settle
